/*
 * @Description: 认证失败过滤器
 * @Author: Haor
 * @Date: 2022-05-09 10:00:21
 * @LastEditTime: 2022-05-09 11:24:38
 * @LastEditors: Haor
 */
import { ArgumentsHost, Catch } from '@nestjs/common'
import { AuthException } from '@exceptions'
import { BaseExceptionFilter } from './base-exception.filter'

@Catch(AuthException)
export class AuthExceptionFilter extends BaseExceptionFilter {
	constructor() {
		super()
		console.log('授权异常构造函数初始化' + new Date().toISOString())
	}

	catch(exception: AuthException, host: ArgumentsHost) {
		exception.exceptionCode = 40002
		console.log('授权异常执行' + new Date().toISOString())
		this.writeToClient(host, exception)
	}
}
